<!--
 * @Description: 销售报价单总览表
 * @Author: Sun
 * @Date: 2019-06-12 21:31:04
 * @LastEditors: Sun
 * @LastEditTime: 2019-06-30 11:31:45
 -->
<template>
	<div class="offcear-Beon clear offcear-Beontu" style="position: relative;z-index: -1;">
		<div class="pool-detailt">报价测算总览</div>
		<div class="fl offcear-fen-left offcear-fen-left2">
			<!-- title -->
			<ul class="clear">
				<li class="fl" v-for="(time, index) in Bmove" :key="index">{{ time }}</li>
			</ul>
			<!-- clear -->
			<div>
				<ul class="clear offcear-fen-rul" v-for="(salesOrder, index) in order.details" :key="index">
					<!-- 序号 -->
					<li class="fl prtext">
						<div>{{ index + 1 }}</div>
					</li>
					<!--产品 -->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.product ? salesOrder.product.code : '产品被删除' }}</span>
						</div>
					</li>
					<!--预估成品单价成本 -->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.forecast_production_cost_price ? toFormatData(salesOrder.forecast_production_cost_price) : '' }}</span>
						</div>
					</li>
					<!-- 预估总成本 -->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.finance_total_cost ? toFormatData(salesOrder.finance_total_cost) : '' }}</span>
						</div>
					</li>
					<!--产品销售报价（本币） -->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.sales_quotations_original_currency ? toFormatData(salesOrder.sales_quotations_original_currency) : '' }}</span>
						</div>
					</li>
					<!-- 预估销售总金额 -->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.finance_total_amount ? toFormatData(salesOrder.finance_total_amount) : '' }}</span>
						</div>
					</li>
					<!-- 预估运输成本 -->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.forecast_transport_cost ? salesOrder.forecast_transport_cost : '' }}%</span>
						</div>
					</li>
					<!-- 预估毛利率 -->
					<li class="fl prtext">
						<div>
							<span v-if="OFasle">{{ salesOrder.forecast_interest_rate ? (salesOrder.forecast_interest_rate * 100).toFixed(4) : '' }}%</span>
							<span v-if="!OFasle">{{ salesOrder.forecast_interest_rate ? (salesOrder.forecast_interest_rate * 100).toFixed(4) : '' }}</span>
						</div>
					</li>
					<!-- 财务分摊 -->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.finance_apportion ? salesOrder.finance_apportion : '' }}%</span>
						</div>
					</li>
					<!-- 预估净利润率 -->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.finance_retained_profits_rate ? (salesOrder.finance_retained_profits_rate * 100).toFixed(4) : '' }}%</span>
						</div>
					</li>
					<!-- 预估净利润 -->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.finance_retained_profits ? toFormatData(salesOrder.finance_retained_profits) : '' }}</span>
						</div>
					</li>
					<!-- 含退税净收益 	净收益=单位净利润 + 单位生产成本 X 出口退税 -->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.profit_with_export_rebates ? salesOrder.profit_with_export_rebates.toFixed(3) : '' }}</span>
						</div>
					</li>
					<!-- 含退税净收益率  净收益比率=净现金流/销售单价-->
					<li class="fl prtext">
						<div>
							<span>{{ salesOrder.profit_rate_with_export_rebates ? (salesOrder.profit_rate_with_export_rebates * 100).toFixed(3) + '%' : '' }}</span>
						</div>
					</li>
				</ul>
			</div>
			<ul class=" clear  offcear-fen-ult">
				<li class="fl"><div></div></li>
				<li class="fl"><div>汇总</div></li>
				<li class="fl"><div></div></li>
				<li class="fl">
					<div>{{ TotalEstimateCostsC }}{{ this.order.total_estimate_costs ? toFormatData(this.order.total_estimate_costs) : '' }}</div>
				</li>
				<li class="fl"><div></div></li>
				<li class="fl">
					<div>{{ TotalSalesAmountC }}{{ this.order.total_sales_amount ? toFormatData(this.order.total_sales_amount) : '' }}</div>
				</li>
				<li class="fl"><div></div></li>
				<li class="fl"><div></div></li>
				<li class="fl"><div></div></li>
				<li class="fl"><div></div></li>
				<li class="fl">
					<div>{{ TotalEstimateProfit }}{{ this.order.total_estimate_profit ? toFormatData(this.order.total_estimate_profit) : '' }}</div>
				</li>
				<li class="fl">
					<div>{{ ExportRebateS }}{{ this.order.total_profit_with_export_rebates ? toFormatData(this.order.total_profit_with_export_rebates) : '' }}</div>
				</li>
				<li class="fl"><div></div></li>
			</ul>
		</div>
	</div>
</template>
<script>
import { mapState, mapActions } from 'vuex';

export default {
	data() {
		return {
			//布行所属往来户类型
			Bmove: [
				'序号',
				'产品',
				'预估生产成本单价',
				'预估总成本',
				'产品销售报价（本币）',
				'预估销售总金额',
				'预估运输成本',
				'预估毛利率',
				'财务分摊',
				'预估净利润率',
				'预估净利润',
				'含退税净收益',
				'净收益比率'
			]
		};
	},
	created() {},
	created() {},
	mounted() {},
	watch: {},
	computed: {
		...mapState({
			order: state => state.offer.order,
			//含退税净收益   profit_with_export_rebates
			ExportRebateS() {
				let that = this;
				let ku = 0;
				if (that.order.details.length > 0) {
					that.order.details.forEach((item, im) => {
						ku += Number(item.profit_with_export_rebates);
					});
					ku ? ku.toFixed(2) : '';
					let boos = {
						data: ku
					};
					return this.$store.commit('offer/ExportRebateS', boos);
					// if (ku != 0 && ku != NaN) {
					// 	ku = ku.toFixed(2);
					// 	let boos = {
					// 		data: ku
					// 	};
					// 	return this.$store.commit('offer/ExportRebateS', boos);
					// } else {
					// 	let boos = {
					// 		data: ''
					// 	};
					// 	return this.$store.commit('offer/ExportRebateS', boos);
					// }
				}
			},
			//预估总成本  total_estimate_costs
			TotalEstimateCostsC() {
				let that = this;
				let ku = 0;
				if (that.order.details.length > 0) {
					that.order.details.forEach((item, im) => {
						ku += Number(item.finance_total_cost);
					});
					if (ku > 0 && ku != NaN) {
						ku = ku.toFixed(2);
						let boos = {
							//   index:inx,
							data: ku
						};
						return this.$store.commit('offer/TotalEstimateCostsC', boos);
					} else {
						let boos = {
							//   index:inx,
							data: ''
						};
						return this.$store.commit('offer/TotalEstimateCostsC', boos);
					}
				}
			},

			//   销售总金额
			TotalSalesAmountC() {
				let that = this;
				let ku = 0;
				if (that.order.details.length > 0) {
					that.order.details.forEach((item, im) => {
						ku += Number(item.finance_total_amount);
					});
					if (ku > 0 && ku != NaN) {
						ku = ku.toFixed(2);
						let boos = {
							//   index:inx,
							data: ku
						};
						return this.$store.commit('offer/TotalSalesAmountC', boos);
					} else {
						let boos = {
							//   index:inx,
							data: ''
						};
						return this.$store.commit('offer/TotalSalesAmountC', boos);
					}
				}
			},

			//  finance_retained_profits 预估净利润
			TotalEstimateProfit() {
				let that = this;
				let ku = 0;
				if (that.order.details.length > 0) {
					that.order.details.forEach((item, im) => {
						ku += Number(item.finance_retained_profits);
					});
					if (ku != 0 && ku != NaN) {
						ku = ku.toFixed(2);
						let boos = {
							// index:inx,
							data: ku
						};
						return this.$store.commit('offer/TotalEstimateProfit', boos);
					} else {
						let boos = {
							// index:inx,
							data: ''
						};
						return this.$store.commit('offer/TotalEstimateProfit', boos);
					}
				}
			}
		})
	},
	methods: {},
	components: {}
};
</script>

<style scoped></style>
